import java.util.Scanner;

public class Test {

    //二维前缀和
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int q = scan.nextInt();
        long[][] a = new long[n + 1][m + 1];
        long[][] sum = new long[n + 1][m + 1];
        for (int i = 1; i <= n ; i++) {
            //初始化一维前缀和
            for (int j = 1; j <= m ; j++) {
                a[i][j] = scan.nextInt();
                sum[i][j] = sum[i][j - 1] + a[i][j];
            }
            //初始化二维前缀和
            for (int j = 1; j <= m ; j++) {
                sum[i][j] += sum[i - 1][j];
            }
        }
        for (int i = 1; i <= q ; i++) {
            int x1 = scan.nextInt();
            int y1 = scan.nextInt();
            int x2 = scan.nextInt();
            int y2 = scan.nextInt();
            System.out.println(getSum(x1,y1,x2,y2,sum));
        }

    }

    private static long getSum(int x1, int y1,int x2,int y2,long[][] sum) {
        if(x1 > x2 || y1 > y2) return 0;
        return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
    }

}
